<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
<title>ComPro Admission</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="<c:url value="/resources/style.css"/>" rel="stylesheet"
	type="text/css" />
<script type="text/javascript" src="resources/js/jquery.js"></script>
<script type="text/javascript" src="resources/js/jquery.form.min.js"></script>
<script type="text/javascript" src="resources/js/cufon-yui.js"></script>
<script type="text/javascript" src="resources/js/arial.js"></script>
<script type="text/javascript" src="resources/js/cuf_run.js"></script>
<script type="text/javascript" src="resources/js/appLogic.js"></script>
<script type="text/javascript">
	$(document)
			.ready(
					function() {
						$('#checkboxd :input').each(
								function() {
									if ($(this).val() != null)
										$(
												":checkbox[value="
														+ $(this).val() + "]")
												.prop("checked", true);
								});

						$('#english').hide();
						$('#education').hide();
						$('#programming').hide();
						$('#prerequisite').hide();
						$('#professional').hide();
						$('#selfstudy').hide();

						$('#personalN').click(function() {
							$('#personal').hide();
							$('#english').show();
							$('#personalForm').submit();
						});

						$('#englishN').click(function() {
							$('#english').hide();
							$('#education').show();
							$('#englishForm').submit();
						});

						$('#educationN').click(function() {
							$('#education').hide();
							$('#programming').show();
							$('#educationForm').submit();
						});

						$('#programmingN').click(function() {
							$('#programming').hide();
							$('#prerequisite').show();
							$('#programmingForm').submit();
						});

						$('#prerequisiteN').click(function() {
							$('#prerequisite').hide();
							$('#professional').show();
							$('#prerequisiteForm').submit();
						});

						$('#professionalN').click(function() {
							$('#professional').hide();
							$('#selfstudy').show();
							$('#professionalForm').submit();
						});

						$('#selfStudyP').click(function() {
							$('#selfstudy').hide();
							$('#professional').show();
						});

						$('#professionalP').click(function() {
							$('#professional').hide();
							$('#prerequisite').show();
						});

						$('#prerequisiteP').click(function() {
							$('#prerequisite').hide();
							$('#programming').show();
						});

						$('#programmingP').click(function() {
							$('#programming').hide();
							$('#education').show();
						});

						$('#educationP').click(function() {
							$('#education').hide();
							$('#english').show();
						});

						$('#englishP').click(function() {
							$('#english').hide();
							$('#personal').show();
						});

						$('#selfStudyS').click(function() {
							window.self.location = "submitApplication";
						});

						var personal = {
							url : "submitPersonal",
							data : $('#personalForm').serialize(),
							type : "POST"
						};

						var englishProficiency = {
							url : "submitEnglish",
							data : $('#englishForm').serialize(),
							type : "POST"
						};

						var educationHistory = {
							url : "submitEducation",
							data : $('#educationForm').serialize(),
							type : "POST"
						};

						var programming = {
							url : "submitProgramming",
							data : $('#programmingForm').serialize(),
							type : "POST"
						};

						var prerequest = {
							url : "submitPrerequisite",
							data : $('#prerequisiteForm').serialize(),
							type : "POST"
						};

						var professional = {
							url : "submitProfessional",
							data : $('#professionalForm').serialize(),
							type : "POST"
						};

						var selfStudy = {
							url : "submitSelfStudy",
							data : $('#selfstudyForm').serialize(),
							type : "POST"
						};

						$('#prerequisiteForm').submit(
								function() {
									$('#preReqHtml').val($('#AcdmExp').html());
									$(this).ajaxSubmit(prerequest);
									$('#savePrerequisites').html(
											'<p>Save successfully!</p>');
									return false;
								});

						$('#selfstudyForm')
								.submit(
										function() {
											$('#selfExpHtml').val(
													$('#SelfExp').html());
											$(this).ajaxSubmit(selfStudy);
											$('#saveselfstudy')
													.html(
															'<p>Save successfully!</p>');
											return false;
										});

						$('#professionalForm')
								.submit(
										function() {
											$('#profExpHtml').val(
													$('#ProfExp').html());
											$(this).ajaxSubmit(professional);
											$('#saveProfessional')
													.html(
															'<p>Save successfully!</p>');
											return false;
										});

						$('#personalForm').submit(
								function() {
									$(this).ajaxSubmit(personal);
									$('#savePersonalInformation').html(
											'<p>Save successfully!</p>');
									return false;
								});

						$('#englishForm').submit(
								function() {
									$(this).ajaxSubmit(englishProficiency);
									$('#saveEnglishProficiency').html(
											'<p>Save successfully!</p>');
									return false;
								});
						$('#educationForm').submit(
								function() {
									$('#eduExpHtml')
											.val($('#Institute').html());
									$(this).ajaxSubmit(educationHistory);
									$('#saveEducation').html(
											'<p>Save successfully!</p>');
									return false;
								});

						$('#programmingForm').submit(
								function() {
									$(this).ajaxSubmit(programming);
									$('#saveProgrammingSkill').html(
											'<p>Save successfully!</p>');
									return false;
								});
						$(
								'#citizenship option[value="${personalInformaion.citizenship}"]')
								.prop("selected", true);
						$(
								'#birthCountry option[value="${personalInformaion.birthCountry}"]')
								.prop("selected", true);
						$(
								'#birthmonth option[value="${personalInformaion.birthmonth}"]')
								.prop("selected", true);
						$(
								'#birthyear option[value="${personalInformaion.birthyear}"]')
								.prop("selected", true);
						$(
								'#birthday option[value="${personalInformaion.birthday}"]')
								.prop("selected", true);
						$(
								'#residence option[value="${personalInformaion.residence}"]')
								.prop("selected", true);
						$('#entry option[value="${personalInformaion.entry}"]')
								.prop("selected", true);
						$(
								'#source option[value="${personalInformaion.source}"]')
								.prop("selected", true);

						$(
								'#readAndWriteEnglish option[value="${englishProficiency.readAndWriteEnglish}"]')
								.prop("selected", true);
						$(
								'#speakEnglish option[value="${englishProficiency.speakEnglish}"]')
								.prop("selected", true);
						$(
								'#understandSpokenEnglish option[value="${englishProficiency.understandSpokenEnglish}"]')
								.prop("selected", true);
						$(
								'#toeflYear option[value="${englishProficiency.toeflYear}"]')
								.prop("selected", true);
						$(
								'#greYear option[value="${englishProficiency.greYear}"]')
								.prop("selected", true);

						$(
								'#programmingJava option[value="${programmingSkill.programmingJava}"]')
								.prop("selected", true);
						$(
								'#programmingCPP option[value="${programmingSkill.programmingCPP}"]')
								.prop("selected", true);
						$(
								'#programmingCsharp option[value="${programmingSkill.programmingCsharp}"]')
								.prop("selected", true);
						$(
								'#programmingC option[value="${programmingSkill.programmingC}"]')
								.prop("selected", true);
						$(
								'#programmingPascal option[value="${programmingSkill.programmingPascal}"]')
								.prop("selected", true);
						$(
								'#programmingVB option[value="${programmingSkill.programmingVB}"]')
								.prop("selected", true);
						$(
								'#programmingOverall option[value="${programmingSkill.programmingOverall}"]')
								.prop("selected", true);
						$(
								'#profLangMost option[value="${professionalExperience.profLangMost}"]')
								.prop("selected", true);
						$(
								'#experienceYears option[value="${professionalExperience.experienceYears}"]')
								.prop("selected", true);
						$(
								'#experienceMonths option[value="${professionalExperience.experienceMonths}"]')
								.prop("selected", true);
						$(
								'#degreeYears option[value="${education.degreeYears}"]')
								.prop("selected", true);
						$(
						'#degreeField option[value="${education.degreeField}"]')
						.prop("selected", true);
						$(
						'#degreeType option[value="${education.degreeType}"]')
						.prop("selected", true);
						$(
						'#degreeCountry option[value="${education.degreeCountry}"]')
						.prop("selected", true);
						$(
						'#gradingScale option[value="${education.gradingScale}"]')
						.prop("selected", true);
						$(
						'#postSecondaryYears option[value="${education.postSecondaryYears}"]')
						.prop("selected", true);
						$(
						'#postSecondaryMonths option[value="${education.postSecondaryMonths}"]')
						.prop("selected", true);
					});
</script>
</head>
<body>
	<div class="checkboxd" id="checkboxd">
		<c:forEach var="checkbox" items="${checkboxValues}">
			<input type="hidden" name="${checkbox }" value="${checkbox }" />
		</c:forEach>
	</div>
	<%@include file="header.jsp"%>
	<div class="main">
		<div class="body">
			<div class="body_resize">
				<div class="left">
					<div id="personal">
						<%@include file="personal.jsp"%>
					</div>
					<div id="english">
						<%@include file="english.jsp"%>
					</div>
					<div id="education">
						<%@include file="education.jsp"%>
					</div>
					<div id="programming">
						<%@include file="programming.jsp"%>
					</div>
					<div id="prerequisite">
						<%@include file="prerequisite.jsp"%>
					</div>
					<div id="professional">
						<%@include file="professional_experience.jsp"%>
					</div>
					<div id="selfstudy">
						<%@include file="self_study.jsp"%>
					</div>
				</div>

				<%@include file="sideuser.jsp"%>
			</div>
			<br />
		</div>


		<%@include file="footer.jsp"%>
	</div>
	<div align=center></div>
</body>
</html>
